//
//  HomeGoodView.m
//  ai2ban
//
//  Created by Luolc on 2018/1/9.
//  Copyright © 2018年 mac book pro. All rights reserved.
//


#import "HomeGoodView.h"
#import <UIImageView+WebCache.h>

@implementation HomeGoodView

-(instancetype)initWithFrame:(CGRect)frame andIcon:(NSString *)icon andTitle:(NSString *)goodsName andPrice:(NSString *)price {
    
    if (self = [super initWithFrame:frame]) {
        
        self.backgroundColor = [UIColor whiteColor];
  
    
        UIImageView *iconImageView = [[UIImageView alloc] init];
        iconImageView.backgroundColor = [UIColor groupTableViewBackgroundColor];
        [iconImageView sd_setImageWithURL:[NSURL URLWithString:icon] placeholderImage:nil];
        iconImageView.frame = CGRectMake(0, 0, self.width, 44);
        [self addSubview:iconImageView];
        
        UILabel *titleLabel = [[UILabel alloc] init];
        titleLabel.text = goodsName;
        titleLabel.font = [UIFont systemFontOfSize:10];
        titleLabel.textColor = [UIColor blackColor];
        titleLabel.numberOfLines = 0;
        titleLabel.frame = CGRectMake(0, iconImageView.bottom+8, self.width, 30);
        titleLabel.textAlignment = NSTextAlignmentCenter;
        [self addSubview:titleLabel];

        
        UILabel *priceLabel = [[UILabel alloc] init];
        priceLabel.text = price;
        priceLabel.font = [UIFont systemFontOfSize:10];
        priceLabel.textColor =  [UIColor colorWithRed:255/255.0 green:104/255.0 blue:26/255.0 alpha:1];
        priceLabel.frame = CGRectMake(0, titleLabel.bottom, self.width, 15);
        priceLabel.textAlignment = NSTextAlignmentCenter;
        [self addSubview:priceLabel];
        
        
    }
    
    return self;
}

@end
